package com.nova.android.tvlauncher.ext

import com.google.gson.Gson
import com.google.gson.reflect.TypeToken
import com.nova.android.tvlauncher.bean.atv_bean.ConfigLocalDto
import com.nova.android.tvlauncher.bean.atv_bean.FavoriteAppRemoteDto
import java.io.File

fun File.toLauncherItems(): List<FavoriteAppRemoteDto> {
    val jsonString = this.readText()
    val gson = Gson()
    val listType = object : TypeToken<List<FavoriteAppRemoteDto>>() {}.type
    return gson.fromJson(jsonString, listType)
}

fun File.toConfigLocalDto(): ConfigLocalDto {
    val jsonString = this.readText()
    val gson = Gson()
    return gson.fromJson(jsonString, ConfigLocalDto::class.java)
}